package chances.wechat.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import chances.wechat.model.BindEvent;
import chances.wechat.service.BaseService;
import chances.wechat.utils.JSONUtils;

/**
 * @author shenxw
 *
 *         2017年5月23日
 */
@Component
public class BindListener {

    @Value("${touping.url}")
    private String toupingUrl;

    @Autowired
    BaseService baseService;

    @EventListener
    public void handlerEvent(BindEvent event) {

        baseService.postMethod(toupingUrl + "/bindmsg/bindevent",
                JSONUtils.fromObject(event));

    }

    
//    public UserRequest toUserRequest(PlayCtrlCmd cmd, String userId) {
//        UserRequest userRequest = new UserRequest();
//        userRequest.setCmd(cmd.getCtrl());
//        userRequest.setType("stb");
//        userRequest.setOpenId(userId);
//        userRequest.setStbNo(cmd.getStbNo());
//        userRequest.setContentCode(cmd.getCode());
//        userRequest.setContentProg(cmd.getProg());
//        userRequest.setContentType(cmd.getType());
//        userRequest.setIcon(cmd.getIcon());
//        userRequest.setTitle(cmd.getTitle());
//        userRequest.setValue(cmd.getValue());
//        return userRequest;
//    }
}
